package com.aqiang.day0528_shop.main.adapter

import android.widget.CheckBox
import com.aqiang.day0528_shop.R
import com.aqiang.day0528_shop.main.entity.ShopTitle
import com.aqiang.lib_core.common.SLog
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseSectionQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder

class CarAdapter(layoutResId: Int, sectionHeadResId: Int, data: MutableList<ShopTitle>): BaseSectionQuickAdapter<ShopTitle,BaseViewHolder>(layoutResId,sectionHeadResId,data) {

    override fun convertHead(helper: BaseViewHolder?, item: ShopTitle) {
        //SLog.d("${item.title}")
        helper?.setText(R.id.tv_item_shoptitle,item.title+"")
        helper?.addOnClickListener(R.id.cb_item_shop)
        var checkBox = helper?.getView<CheckBox>(R.id.cb_item_shop)
        checkBox?.isChecked = item.inclu
    }

    override fun convert(helper: BaseViewHolder?, item: ShopTitle) {
        helper?.setText(R.id.tv_item_b_name,item.t.tilte+"")
        helper?.setText(R.id.tv_item_b_price,"￥"+item.t.price)
        helper?.setText(R.id.tv_item_b_num,"${item.t.num}")
        var checkBox = helper?.getView<CheckBox>(R.id.cb_item_b)
        checkBox?.isChecked = item.t.inclu
        helper?.addOnClickListener(R.id.tv_item_b_add)
        helper?.addOnClickListener(R.id.tv_item_b_del)
        Glide.with(mContext)
            .load(item.t.price)
            .into(helper!!.getView(R.id.iv_item_b))

    }
}
